package com.auxgroup.smarthome.inner.service;

import com.auxgroup.smarthome.BeanListUtils;
import com.auxgroup.smarthome.inner.entity.BaseCodesEntity;
import com.auxgroup.smarthome.inner.repo.BaseCodesEntityRepo;
import com.auxgroup.smarthome.inner.vo.BaseCodesVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by root on 17-7-25.
 */
@Service
public class BaseCodesDBService {
    @Autowired
    private BaseCodesEntityRepo baseCodesEntityRepo;

    /**
     * 获取基本字典
     * @param typeCode
     * @return
     */
    public List<BaseCodesVo> findBaseCodes(String typeCode){
        List<BaseCodesEntity>  baseCodesEntitys = baseCodesEntityRepo.findByTypeCode(typeCode);
        BeanListUtils beanListUtils = new BeanListUtils(BaseCodesVo.class,baseCodesEntitys);
        return beanListUtils.getTargetList();
    }

    /**
     * 获取所有数据字典
     * @param
     * @return
     */
    public List<BaseCodesVo> findAll(){
        List<BaseCodesEntity>  baseCodesEntitys = baseCodesEntityRepo.findAll();
        BeanListUtils beanListUtils = new BeanListUtils(BaseCodesVo.class,baseCodesEntitys);
        return beanListUtils.getTargetList();
    }

}
